﻿/*
* Copyright 2004-2010 mb_sx@hotmail.com
* All Rights Reserved.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DeskNotes.Utils;

namespace DeskNotes
{
    class SearchResultItem : ListViewItem
    {
        private long id;
        private List<SearchedText> searchQuery;
        private ArchivedNoteNode nodeNote = null;
        
        
        internal SearchResultItem(string text, long id, List<SearchedText> search) : base()
        {
            string t;
            if (text.Length > 30)
                t = RtfConverter.Text(text).Substring(0, 30);
            else
                t = RtfConverter.Text(text).Substring(0, text.Length-1);
            base.Text = t.Replace("\n", " ");
            this.id = id;
            this.searchQuery = search;
            ImageIndex = ArchiveForm.NOTE_IMAGE;
            base.SubItems.Add(new ListViewSubItem());
        }

        internal long ID
        {
            get
            {
                return id;
            }
        }

        internal List<SearchedText> SearchedText
        {
            get
            {
                return searchQuery;
            }
        }

       

        internal ArchivedNoteNode TreeNode
        {
            set
            {
                nodeNote = value;
            }
            get
            {
                return nodeNote;
            }
        }
    }

    class SearchedText
    {
        internal int selectionStart, length;
        internal string selectedRtf;
        internal string searchTerm;

        internal SearchedText (string searchTerm){
            this.searchTerm = searchTerm;
        }

        internal void Selection(int start, int length, string rtf)
        {
            selectionStart = start;
            this.length = length;
            selectedRtf = rtf;
        }
    }
}
